package org.sourceprojects.pannonia;

import java.util.List;

public class EventManagerUtilities {

	private static final EventManager EVENT_MANAGER = EventManagerFactory.newInstance();
	
	public static final <T> void announceMessage(Message<T> message) {
		EVENT_MANAGER.announceMessage(message);
	}

	public static final <T> Message<T> dequeueMessage(String name) {
		return EVENT_MANAGER.dequeueMessage(name);
	}

	public static final <T> T fireEvent(Event event) {
		return EVENT_MANAGER.fireEvent(event);
	}

	public static final <T> T fireEvent(Event event, Object... arguments) {
		return EVENT_MANAGER.fireEvent(event, arguments);
	}

	public static final <T> T fireEvent(Object receiver, Event event) {
		return EVENT_MANAGER.fireEvent(receiver, event);
	}

	public static final <T> T fireEvent(Object receiver, Event event, Object... arguments) {
		return EVENT_MANAGER.fireEvent(receiver, event, arguments);
	}

	public static final Queue getQueue(String name) {
		return EVENT_MANAGER.getQueue(name);
	}

	public static final <T> void postQueueMessage(String name, Message<T> message) {
		EVENT_MANAGER.postQueueMessage(name, message);
	}

	public static final <T> void postTopicMessage(Topic topic, Message<T> message) {
		EVENT_MANAGER.postTopicMessage(topic, message);
	}

	public static final <T> List<Message<T>> queryTopic(Topic topic) {
		return EVENT_MANAGER.queryTopic(topic);
	}

	public static final void registerEventHandler(MarkedEventHandler eventHandler) {
		EVENT_MANAGER.registerEventHandler(eventHandler);
	}

	public static final void registerEventHandler(Object eventHandler) {
		EVENT_MANAGER.registerEventHandler(eventHandler);
	}

	public static final void removeEventHandler(MarkedEventHandler eventHandler) {
		EVENT_MANAGER.removeEventHandler(eventHandler);
	}

	public static final void removeEventHandler(Object eventHandler) {
		EVENT_MANAGER.removeEventHandler(eventHandler);
	}
	
	public static final <T> void registerQueue(String name, Callback<T> callback) {
		EVENT_MANAGER.registerQueue(name, callback);
	}

	public static final <T> void registerTopic(Topic topic, Callback<T> callback) {
		EVENT_MANAGER.registerTopic(topic, callback);
	}

	public static final <T> void removeTopicMessage(Topic topic, Message<T> message) {
		EVENT_MANAGER.removeTopicMessage(topic, message);
	}

}
